package com.baidu.mapapi;

import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.drawable.Drawable;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.WindowManager;
import android.widget.Toast;
import java.util.ArrayList;

public class TransitOverlay extends ItemizedOverlay<OverlayItem>
{
  private ArrayList<a> a = null;
  private MapView b = null;
  private Context c = null;
  private int d = 1;
  private DisplayMetrics e;
  public MKTransitRoutePlan mPlan = null;
  public boolean mUseToast = true;

  public TransitOverlay(Activity paramActivity, MapView paramMapView)
  {
    super(null);
    this.c = paramActivity;
    this.b = paramMapView;
    this.e = new DisplayMetrics();
    paramActivity.getWindowManager().getDefaultDisplay().getMetrics(this.e);
    if ((this.e.widthPixels <= 320) && (this.e.heightPixels <= 320))
    {
      this.d = 0;
      return;
    }
    if ((this.e.widthPixels <= 480) && (this.e.heightPixels <= 480))
    {
      this.d = 1;
      return;
    }
    this.d = 2;
  }

  public void animateTo()
  {
    if (size() > 0)
      onTap(0);
  }

  protected OverlayItem createItem(int paramInt)
  {
    char[] arrayOfChar = { 108, 109, 104 };
    String[] arrayOfString = { "start", "end", "bus", "foot", "rail", "car" };
    a locala = (a)this.a.get(paramInt);
    OverlayItem localOverlayItem = new OverlayItem(locala.b, locala.a, null);
    Drawable localDrawable;
    if (locala.c != 3)
    {
      StringBuilder localStringBuilder = new StringBuilder(32);
      localStringBuilder.append("icon_nav_").append(arrayOfString[locala.c]).append('_').append(arrayOfChar[this.d]).append(".png");
      localDrawable = k.a(this.c, localStringBuilder.toString());
      if ((locala.c == 0) || (locala.c == 1))
        localOverlayItem.setMarker(boundCenterBottom(localDrawable));
    }
    else
    {
      return localOverlayItem;
    }
    localOverlayItem.setMarker(boundCenter(localDrawable));
    return localOverlayItem;
  }

  public boolean draw(Canvas paramCanvas, MapView paramMapView, boolean paramBoolean, long paramLong)
  {
    Projection localProjection = paramMapView.getProjection();
    ((Activity)this.c).getWindowManager().getDefaultDisplay().getMetrics(this.e);
    if (this.mPlan != null)
    {
      int i = this.mPlan.getNumLines();
      int j = this.mPlan.getNumRoute();
      if ((i + 1 == j) && (i != 0))
      {
        Paint localPaint = new Paint();
        localPaint.setAntiAlias(true);
        localPaint.setStrokeWidth(6.0F);
        Point localPoint1 = new Point();
        Point localPoint2 = new Point();
        ArrayList localArrayList1 = new ArrayList();
        int k = paramMapView.getZoomLevel();
        for (int m = 0; m < i; m++)
        {
          MKRoute localMKRoute1 = this.mPlan.getRoute(m);
          ArrayList localArrayList2 = localMKRoute1.getArrayPoints();
          if ((localArrayList2 != null) && (localArrayList2.size() > 0))
          {
            ArrayList localArrayList6 = (ArrayList)localArrayList2.get(0);
            if ((localArrayList6 != null) && (localArrayList6.size() > 0))
            {
              k.a(localArrayList6, (ArrayList)localMKRoute1.a.get(0), k, localArrayList1);
              int i4 = localArrayList1.size();
              if (i4 > 1)
              {
                localPaint.setColor(Color.rgb(48, 162, 8));
                localPaint.setAlpha(192);
                localProjection.toPixels((GeoPoint)localArrayList1.get(0), localPoint1);
                for (int i5 = 1; i5 < i4; i5++)
                {
                  localProjection.toPixels((GeoPoint)localArrayList1.get(i5), localPoint2);
                  if (k.a(localPoint1, localPoint2, this.e.widthPixels, this.e.heightPixels))
                    paramCanvas.drawLine(localPoint1.x, localPoint1.y, localPoint2.x, localPoint2.y, localPaint);
                  localPoint1.x = localPoint2.x;
                  localPoint1.y = localPoint2.y;
                }
              }
            }
          }
          MKLine localMKLine = this.mPlan.getLine(m);
          ArrayList localArrayList3 = localMKLine.getPoints();
          if ((localArrayList3 != null) && (localArrayList3.size() > 0))
          {
            k.a(localArrayList3, localMKLine.a, k, localArrayList1);
            int i2 = localArrayList1.size();
            if (i2 > 1)
            {
              localPaint.setColor(Color.rgb(58, 107, 189));
              localPaint.setAlpha(192);
              localProjection.toPixels((GeoPoint)localArrayList1.get(0), localPoint1);
              for (int i3 = 1; i3 < i2; i3++)
              {
                localProjection.toPixels((GeoPoint)localArrayList1.get(i3), localPoint2);
                if (k.a(localPoint1, localPoint2, this.e.widthPixels, this.e.heightPixels))
                  paramCanvas.drawLine(localPoint1.x, localPoint1.y, localPoint2.x, localPoint2.y, localPaint);
                localPoint1.x = localPoint2.x;
                localPoint1.y = localPoint2.y;
              }
            }
          }
          if (m == i - 1)
          {
            MKRoute localMKRoute2 = this.mPlan.getRoute(m + 1);
            ArrayList localArrayList4 = localMKRoute2.getArrayPoints();
            if ((localArrayList4 == null) || (localArrayList4.size() <= 0))
              break;
            ArrayList localArrayList5 = (ArrayList)localArrayList4.get(0);
            if ((localArrayList5 == null) || (localArrayList5.size() <= 0))
              break;
            k.a(localArrayList5, (ArrayList)localMKRoute2.a.get(0), k, localArrayList1);
            int n = localArrayList1.size();
            if (n <= 1)
              break;
            localPaint.setColor(Color.rgb(48, 162, 8));
            localPaint.setAlpha(192);
            localProjection.toPixels((GeoPoint)localArrayList1.get(0), localPoint1);
            for (int i1 = 1; i1 < n; i1++)
            {
              localProjection.toPixels((GeoPoint)localArrayList1.get(i1), localPoint2);
              if (k.a(localPoint1, localPoint2, this.e.widthPixels, this.e.heightPixels))
                paramCanvas.drawLine(localPoint1.x, localPoint1.y, localPoint2.x, localPoint2.y, localPaint);
              localPoint1.x = localPoint2.x;
              localPoint1.y = localPoint2.y;
            }
          }
        }
      }
    }
    return super.draw(paramCanvas, paramMapView, paramBoolean, paramLong);
  }

  protected boolean onTap(int paramInt)
  {
    OverlayItem localOverlayItem = getItem(paramInt);
    this.b.getController().animateTo(localOverlayItem.mPoint);
    if ((this.mUseToast) && (localOverlayItem.mTitle != null))
      Toast.makeText(this.c, localOverlayItem.mTitle, 1).show();
    super.onTap(paramInt);
    return true;
  }

  public void setData(MKTransitRoutePlan paramMKTransitRoutePlan)
  {
    if (paramMKTransitRoutePlan == null);
    int i;
    int j;
    do
    {
      return;
      this.a = new ArrayList();
      this.mPlan = paramMKTransitRoutePlan;
      i = paramMKTransitRoutePlan.getNumLines();
      j = this.mPlan.getNumRoute();
    }
    while ((i + 1 != j) || (i == 0));
    GeoPoint localGeoPoint1 = paramMKTransitRoutePlan.getStart();
    int k = 0;
    if (localGeoPoint1 != null)
    {
      a locala1 = new a(null);
      locala1.b = localGeoPoint1;
      locala1.c = 0;
      this.a.add(locala1);
    }
    if (k < i)
    {
      MKLine localMKLine = paramMKTransitRoutePlan.getLine(k);
      a locala3 = new a(null);
      locala3.b = localMKLine.getGetOnStop().pt;
      locala3.a = localMKLine.a();
      label155: a locala4;
      if (localMKLine.getType() == 0)
      {
        locala3.c = 2;
        this.a.add(locala3);
        MKRoute localMKRoute = this.mPlan.getRoute(k + 1);
        locala4 = new a(null);
        locala4.b = localMKLine.getGetOffStop().pt;
        locala4.a = localMKRoute.a();
        if (localMKLine.getType() != 0)
          break label251;
      }
      label251: for (locala4.c = 2; ; locala4.c = 4)
      {
        this.a.add(locala4);
        k++;
        break;
        locala3.c = 4;
        break label155;
      }
    }
    GeoPoint localGeoPoint2 = paramMKTransitRoutePlan.getEnd();
    if (localGeoPoint2 != null)
    {
      a locala2 = new a(null);
      locala2.b = localGeoPoint2;
      locala2.c = 1;
      this.a.add(locala2);
    }
    super.populate();
  }

  public int size()
  {
    if (this.a == null)
      return 0;
    return this.a.size();
  }

  private class a
  {
    public String a;
    public GeoPoint b;
    public int c;

    private a()
    {
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.baidu.mapapi.TransitOverlay
 * JD-Core Version:    0.6.2
 */